package com.chixing.controller;


import com.chixing.entity.Product;
import com.chixing.service.IProductService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-09-28
 */
@CrossOrigin
@RestController
@RequestMapping("/product")
public class ProductController {
    @Autowired
    private IProductService productService;

    @GetMapping("{id}")
    public Result selectProduct(@PathVariable("id") Integer id){
        return productService.getById(id);
    }

    @GetMapping("hot")
    public Result getHotProducts(){
        return productService.getHotProduct();
    }

    @GetMapping("decr/{proId}")
    public Result decrProduct(@PathVariable("proId") Integer proId){
        return productService.decrProCount(proId);
    }

}
